package statics;

import java.io.IOException;
import java.net.URLDecoder;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.jsoup.Jsoup;

public class ExportExcel extends HttpServlet{
	public void doGet(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException {
		response.setCharacterEncoding("UTF-8");
		String url = URLDecoder.decode((String) request.getParameter("url"));;
		
		String content = Jsoup.connect(url).get().select("body").html();
		
		response.setHeader("Cache-Control", "");
		response.setHeader("Pragma", "");
		response.setHeader("Content-Disposition", "attachment; filename=export.xls");
		response.setContentType("application/vnd.ms-excel");
		response.getWriter().println(content);
	}
}
